//go:build windows

package tool

import (
	"fmt"
	"golang.org/x/sys/windows"
)

// 列出windows系统中的盘符，仅能在windows系统下编译
func ListDriversInWindows() ([]string, error) {
	var drivers []string
	logicalDrives, err := windows.GetLogicalDrives()
	if err != nil {
		return drivers, err
	}

	// 遍历每一位，检查驱动器是否存在
	for i := 0; i < 26; i++ {
		if logicalDrives&(1<<uint(i)) != 0 {
			// 将驱动器字母转换为字符串（例如 'C' -> "C:"）
			drive := fmt.Sprintf("%c:", 'A'+i)
			drivers = append(drivers, drive)
		}
	}

	return drivers, nil
}
